#!/usr/bin/env python
# Create: 2018/10/23
__author__ = '749B'
"""asyncio 用法"""

import asyncio


@asyncio.coroutine
def func(n):
    print('before func %s...' % n)
    yield from asyncio.sleep(3)
    print('end func %s...' % n)


if __name__ == '__main__':
    tasks = []
    for i in range(5):
        tasks.append(func(i))
    loop = asyncio.get_event_loop()
    loop.run_until_complete(asyncio.gather(*tasks))
    loop.close()

